<?php
require_once('lib/db_connection.php');
$_SESSION['company_id'] ='49';
//ALPHABETICAL ORDER BULK, CARGO, TRAILER

$query_tc_inline = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='inline' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='TC'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_inline = mysql_query($query_tc_inline) or die("SELECT TC INLINE ".mysql_error());
$tc_inline = array();
while($row_tc_inline = mysql_fetch_array($result_tc_inline))
{
 $tc_inline[$row_tc_inline['style_name']] = $row_tc_inline['count'];
}


$query_vc_inline = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='inline' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='VC'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_inline = mysql_query($query_vc_inline) or die("SELECT VC INLINE ".mysql_error());
$vc_inline = array();
while($row_vc_inline = mysql_fetch_array($result_tc_inline))
{
 $vc_inline[$row_vc_inline['style_name']] = $row_vc_inline['count'];
}



$query_tc_loading = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='loading' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='TC'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_loading = mysql_query($query_tc_loading) or die("SELECT TC LOADING ".mysql_error());
$tc_loading = array();
while($row_tc_loading = mysql_fetch_array($result_tc_loading))
{
 $tc_loading[$row_tc_loading['style_name']] = $row_tc_loading['count'];
}

$query_vc_loading = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='loading' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='VC'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_loading = mysql_query($query_vc_loading) or die("SELECT VC LOADING ".mysql_error());
$vc_loading = array();
while($row_vc_loading = mysql_fetch_array($result_tc_loading))
{
 $vc_loading[$row_vc_loading['style_name']] = $row_vc_loading['count'];
}



$query_tc_loaded = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='loaded' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='TC'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_loaded = mysql_query($query_tc_loaded) or die("SELECT TC loaded ".mysql_error());
$tc_loaded = array();
while($row_tc_loaded = mysql_fetch_array($result_tc_loaded))
{
 $tc_loaded[$row_tc_loaded['style_name']] = $row_tc_loaded['count'];
}

$query_vc_loaded = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='loaded' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='VC'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_loaded = mysql_query($query_vc_loaded) or die("SELECT VC loaded ".mysql_error());
$vc_loaded = array();
while($row_vc_loaded = mysql_fetch_array($result_tc_loaded))
{
 $vc_loaded[$row_vc_loaded['style_name']] = $row_vc_loaded['count'];
}



$query_tc_complete = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='complete' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='TC'
AND queue_tbl.complete_timestamp LIKE '".date('Y-m-d')."%'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_complete = mysql_query($query_tc_complete) or die("SELECT TC complete ".mysql_error());
$tc_complete = array();
while($row_tc_complete = mysql_fetch_array($result_tc_complete))
{
 $tc_complete[$row_tc_complete['style_name']] = $row_tc_complete['count'];
}

$query_vc_complete = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='complete' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='VC'
AND queue_tbl.complete_timestamp LIKE '".date('Y-m-d')."%'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_complete = mysql_query($query_vc_complete) or die("SELECT VC complete ".mysql_error());
$vc_complete = array();
while($row_vc_complete = mysql_fetch_array($result_tc_complete))
{
 $vc_complete[$row_vc_complete['style_name']] = $row_vc_complete['count'];
}



$query_tc_intransit = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='intransit' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='TC'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_intransit = mysql_query($query_tc_intransit) or die("SELECT TC intransit ".mysql_error());
$tc_intransit = array();
while($row_tc_intransit = mysql_fetch_array($result_tc_intransit))
{
 $tc_intransit[$row_tc_intransit['style_name']] = $row_tc_intransit['count'];
}

$query_vc_intransit = "SELECT count(queue_tbl.plate_no) as count, dts_veh_tbl.style_name as style_name
FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id = dts_veh_tbl.vehicle_id
WHERE queue_tbl.status='intransit' AND dts_veh_tbl.company_id='".$_SESSION['company_id']."' AND queue_tbl.hauler_type='VC'
GROUP BY dts_veh_tbl.style_name 
ORDER BY dts_veh_tbl.style_name";
$result_tc_intransit = mysql_query($query_vc_intransit) or die("SELECT VC intransit ".mysql_error());
$vc_intransit = array();
while($row_vc_intransit = mysql_fetch_array($result_tc_intransit))
{
 $vc_intransit[$row_vc_intransit['style_name']] = $row_vc_intransit['count'];
}
?>
<html>
<body>
<br /><br />
<p style='font-weight:bold;text-decoration:underline;text-align:center;color:white;'>INLINE</p>
<table border='1' style='width:290px;margin-left:0%;margin-right:0%;'>
	<tr>
		<th style='width:72.5px;color:white;'>&nbsp;</th>
		<th style='width:72.5px;color:white;'>CARGO</th>
		<th style='width:72.5px;color:white;'>TRAILER</th>
		<th style='width:72.5px;color:white;'>BULK</th>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>TC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_inline['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_inline['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_inline['bulk'])?></td>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>VC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_inline['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_inline['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_inline['bulk'])?></td>
	</tr>
</table>


<p style='font-weight:bold;text-decoration:underline;text-align:center;color:white;'>LOADING</p>
<table border='1' style='width:290px;margin-left:0%;margin-right:0%;'>
	<tr>
		<th style='width:72.5px;color:white;'>&nbsp;</th>
		<th style='width:72.5px;color:white;'>CARGO</th>
		<th style='width:72.5px;color:white;'>TRAILER</th>
		<th style='width:72.5px;color:white;'>BULK</th>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>TC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_loading['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_loading['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_loading['bulk'])?></td>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>VC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_loading['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_loading['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_loading['bulk'])?></td>
	</tr>
</table>


<p style='font-weight:bold;text-decoration:underline;text-align:center;color:white;'>LOADED</p>
<table border='1' style='width:290px;margin-left:0%;margin-right:0%;'>
	<tr>
		<th style='width:72.5px;color:white;'>&nbsp;</th>
		<th style='width:72.5px;color:white;'>CARGO</th>
		<th style='width:72.5px;color:white;'>TRAILER</th>
		<th style='width:72.5px;color:white;'>BULK</th>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>TC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_loaded['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_loaded['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_loaded['bulk'])?></td>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>VC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_loaded['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_loaded['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_loaded['bulk'])?></td>
	</tr>
</table>



<p style='font-weight:bold;text-decoration:underline;text-align:center;color:white;'>TRUCK ARRIVED SINCE 12:00AM</p>
<table border='1' style='width:290px;margin-left:0%;margin-right:0%;'>
	<tr>
		<th style='width:72.5px;color:white;'>&nbsp;</th>
		<th style='width:72.5px;color:white;'>CARGO</th>
		<th style='width:72.5px;color:white;'>TRAILER</th>
		<th style='width:72.5px;color:white;'>BULK</th>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>TC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_complete['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_complete['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_complete['bulk'])?></td>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>VC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_complete['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_complete['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_complete['bulk'])?></td>
	</tr>
</table>



<p style='font-weight:bold;text-decoration:underline;text-align:center;color:white;'>EXPECTED TRUCK THIS DAY</p>
<table border='1' style='width:290px;margin-left:0%;margin-right:0%;'>
	<tr>
		<th style='width:72.5px;color:white;'>&nbsp;</th>
		<th style='width:72.5px;color:white;'>CARGO</th>
		<th style='width:72.5px;color:white;'>TRAILER</th>
		<th style='width:72.5px;color:white;'>BULK</th>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>TC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_intransit['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_intransit['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($tc_intransit['bulk'])?></td>
	</tr>
	<tr>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'>VC</td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_intransit['cargo'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_intransit['trailer'])?></td>
		<td style='font-size:12px;width:72.5px;color:white;text-align:center;'><?php echo intval($vc_intransit['bulk'])?></td>
	</tr>
</table>
</body>
</html>

